<template>
	<div class="main-wrapper">
		<group :title="groupObj.title">
	
			<x-input text-align="left" type="number" title="快递单号" v-model="expressNum">
			</x-input>
			<x-input text-align="left" type="text" title="商品昵称" v-model="expressName">
			</x-input>
		</group>
		
		<Flexbox>
			<FlexboxItem>
				<XButton class="add-express-btn" @click.native="goBack()" action-type="button" style="margin-top:1rem;background-color:#ccc;" type="default">返回</XButton>
			</FlexboxItem>
			<FlexboxItem>
				<XButton class="add-express-btn" @click.native="addExpress()" action-type="button" style="margin-top:1rem;" type="primary">添加快递</XButton>
			</FlexboxItem>
		</Flexbox>
	</div>
</template>
<script>
import { XButton, XInput, Group, Flexbox, FlexboxItem } from 'vux';
import checkLogin from '../myUtils/checkLogin';
export default {
	data() {
		return {
			expressNum: 0,
			expressName: '',
			groupObj: {
				title: '添加快递',
				expressNumPh: '必须是数字',
				expressNamePh: '必须是数字',
				title2: '添加快递',
			}
		}
	},
	created() {
		checkLogin(this);
	},
	methods: {
		goBack() {
			this.$router.go(-1);
		},
		addExpress() {
			var self = this;
			var r1 = this.checkValue(this.expressNum, '请输入快递单号！');
			var r2 = this.checkValue(this.expressNum, '请输入商品昵称！');
			if (r1 && r2) {
				this.$vux.alert.show({
					title: '',
					content: '添加成功！',
					onHide() {
						self.$router.go(-1);
					}
				});
			};
			console.log('addExpress()')
		},
		checkValue(v, remind) {
			if (!(v && v.length)) {
				this.toastText(remind);
				return false;
			}
			return true;
		},
		toastText(text, type) {
			this.$vux.toast.show({
				type: type || 'text',
				text: text,
				position: 'middle',
			});
		}
	},
	components: {
		XButton,
		Flexbox,
		FlexboxItem,
		XInput,
		Group
	},
}
</script>
<style>

</style>
